package com.xidian.zhiancloud.three.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import com.github.pagehelper.Page;
import com.xidian.zhiancloud.dto.ResultDTO;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.model.exam.TExamPaper;
import com.xidian.zhiancloud.three.domain.Three;
import com.xidian.zhiancloud.three.service.IThreeService;

/**
 * 三违管理Controller
 * 
 * @author zhouweitao
 * @date 2021-04-08
 */
@RestController
@Api(tags="三违管理")
@RequestMapping("/three")
public class ThreeController 
{
    @Autowired
    private IThreeService threeService;

    /**
     * 查询三违管理列表
     */
	 @ApiOperation(value = "查询三违管理列表", notes = "注意传入值")
    @ApiImplicitParams(value={
    	       @ApiImplicitParam(name="pageNum",value = "当前记录起始索引", dataType = "int",required = true),
    	       @ApiImplicitParam(name="pageSize",value = "每页显示记录数 ",dataType = "int",required = true),
    	       @ApiImplicitParam(name="orderByColumn",value = "排序列 默认值：create_time",dataType = "String",required = true),
    	       @ApiImplicitParam(name="isAsc",value = "排序列 默认值：DESC",dataType = "String",required = true)
    	})
    @GetMapping("/list")
    public ResultDTO list(Three three)
    {
		 Page<Three> pagedata = threeService.selectThreeList(three);
        Map<String, Object> data = new HashMap<String, Object>();
		data.put("datalist", pagedata);
		data.put("PageNum", pagedata.getPageNum()+1);
		data.put("PageSize", pagedata.getPageSize());
		data.put("PageTotal", pagedata.getPages());
		data.put("total", pagedata.getTotal());
		return ResultDTO.successOf(data,GeneralResponseEnums.SUCCESS);
    }

 

    /**
     * 获取三违管理详细信息
     */
    @GetMapping(value = "/{id}")
    public ResultDTO getInfo(@PathVariable("id") Long id)
    {
    	 return ResultDTO.successOf(threeService.selectThreeById(id),GeneralResponseEnums.SUCCESS);
    }

    /**
     * 新增三违管理
     */
    @PostMapping("/add")
    public ResultDTO add( Three three)
    {
        threeService.insertThree(three);
    	return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
    }

    /**
     * 修改三违管理
     */
    @PutMapping("/update")
    public ResultDTO edit(Three three)
    {
        threeService.updateThree(three);
    	return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
    }

    /**
     * 删除三违管理
     */
	@DeleteMapping("/{ids}")
    public ResultDTO remove(@PathVariable Long[] ids)
    {
        threeService.deleteThreeByIds(ids);
		return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
    }
}
